package com.tencent.sr.iris.basic.saas.service.model.advisor;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.tencent.sr.iris.activity.interfaces.response.group.AdvisorBoardSprintSecondResponse;
import com.tencent.sr.iris.user.core.service.interfaces.enums.UserLevelEnum;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Optional;

@Data
@Slf4j
@ColumnWidth(15)
public class AdvisorBoardSprintExportInfo {

    @ExcelProperty(value = "序号", index = 0)
    private int num;

    @ExcelProperty(value = "报名时间", index = 1)
    private String taskPhaseJoinTime;

    @ExcelProperty(value = "团长uid", index = 2)
    private String irisUid;

    @ExcelProperty(value = "unionId", index = 3)
    private String wechatUserUnionid;

    @ExcelProperty(value = "昵称", index = 4)
    private String wechatUserNickname;

    @ExcelProperty(value = "等级", index = 5)
    private String irisUidLevel;


    public void readFromSearchResponseData(AdvisorBoardSprintSecondResponse response) {
        this.setTaskPhaseJoinTime(response.getTaskPhaseJoinTime());
        this.setIrisUid(response.getIrisUid());
        this.setWechatUserUnionid(response.getWechatUserUnionid());
        this.setWechatUserNickname(response.getWechatUserNickname());

        String levelText = Optional.ofNullable(UserLevelEnum.getByValue(response.getIrisUidLevel()))
                .map(UserLevelEnum::getDesc).orElse(StrUtil.EMPTY);
        this.setIrisUidLevel(levelText);
    }

}
